<?php
//include_once("model/itemConfig.php");
//var_dump($organization->getAuthorized());
		    global $itemType;
			global $itemTopSize;
			global $itemSize;
			global $itemColor;
			global $itemMaterial;
			global $itemSeason;
			global $itemYear;
			global $itemType;
			global $itemDesigner;
			global $organizationType;
?>
	<div class="block">

	<div class="invertedshiftdown">
<ul>
	<?php
	if($organization->type=='s'){
	?>
			<li><a href="?page=organization_inventory&id=<?php echo $organization->id; ?>">查看货存</a></li>
			<li><a href="?page=organization_sell&id=<?php echo $organization->id; ?>">出售</a></li>
			<li><a href="?page=organization_return&id=<?php echo $organization->id; ?>">退款</a></li>
			<li class="current"><a href="?page=organization_distribute&id=<?php echo $organization->id; ?>">分配</a></li>
			<li><a href="?page=organization_distribute_confirm&id=<?php echo $organization->id; ?>">处理待定分配</a></li>
			<li><a href="?page=organization_transaction&id=<?php echo $organization->id; ?>">查看物流记录</a></li>
			<li><a href="?page=organization_sell_record&id=<?php echo $organization->id; ?>">查看销售记录</a></li>
	<?php
	}elseif($organization->type=='w'){
	?>
	       	<li><a href="?page=organization_inventory&id=<?php echo $organization->id; ?>">查看库存</a></li>
			<li><a href="?page=organization_stack&id=<?php echo $organization->id; ?>">入库</a></li>
			<li class="current"><a href="?page=organization_distribute&id=<?php echo $organization->id; ?>">分配</a></li>
			<li><a href="?page=organization_distribute_confirm&id=<?php echo $organization->id; ?>">处理待定分配</a></li>
			<li><a href="?page=organization_transaction&id=<?php echo $organization->id; ?>">查看物流记录</a></li>
			
    <?php
	}
	?>
</ul>




<form id="myform">
<input type="text" class="textinput" /> <input class="submit" type="submit" value="搜索" />
</form>
</div>

<br style="clear: both;" />
<div id= 'content'>

	<?php
	//print_r($_GET);
	if(isset($_GET['stat'])){
		if($_GET['stat']=='distributed'){
			
		
	
	?>
	<div class="isa_success">
		<h4>操作成功：</h4>分配
	</div>
	
	<?php
		}elseif($_GET['stat']=='error'&&$_GET['error']=='limit'){
	?>
	<div class="isa_warning">
		<h4>操作失败：</h4>无法分配（货存数量有限）
	</div>
	
		<?php
		}elseif($_GET['stat']=='error'&&$_GET['error']=='badData'){
	?>
	<div class="isa_warning">
		<h4>操作失败：</h4>无法分配（提交了无效数据）
	</div>
<?php

		}
}
?>

		<h2><?php echo $organization->name ?>》库存分配界面</h2>
				<h4><?php echo $organization->name ?>库存显示</h4>

<form action="api/" method="post">
        	<input type="hidden" id='action' name="action" value="organization_distribute" />
        	<input type="hidden" id='user1' name="user1" value="<?php echo $currentUser->id ?>" />
        	<input type="hidden" id='source' name="source" value="<?php echo  $organization->id ?>" />        	
	<?php echo $table;?>
		<br>
<br>

	

    
    
    <hr>
   
    	<h4>选择以上的其中一种产品,然后再填写数量和分配目的地</h4>
    	<div class="important">若要分配货物的形码若没能在上面列表找到请联络管理员</div>
    	<br>
    	
		   <div class="element" style="clear:both;">
            <label class="form">选择分配到：</label>
		   <select name="target">
             <?php
             foreach ($allOrganizations as  $org) {
             	$id = $org->id;
             	$name =$org->name;
				
				if($id!=$organization->id){
             ?>
             <option value='<?php echo $id;?>' ><?php echo $name;?></option>
             <?php
                }
              }
             ?>
             </select>
             </div>
              <div class="element" style="clear:both;">
               <label class="form">数目</label>
             <input type="text" name="number" value="" >
             </div>
             <?php
if(count($organization->getInventory())){
             ?>
             <div class="element" style="clear:both;">
             <input type="submit" value="分配" />
             </div>
             <?php
}else{
             ?>
             <div class="element" style="clear:both;">
             <input type="submit" value="分配" disabled />
             </div>
             <?php
}
             ?>
		    </form>

<br>
<br>
<br>


   
<div class="clear"></div>
	</div>